﻿Imports System.IO.Stream
Imports OpenIso8583Net
Imports System.IO

Module StartUP

    Public Sub Main()
        Console.WriteLine()

        Dim A As New Message
        Dim Strim As New HexStream
        A.Type = 1800
        A.SetField(3, FieldTypes.TYPE_N, 6, 990000)
        A.SetField(11, FieldTypes.TYPE_N, 6, 25)
        A.SetField(20, FieldTypes.TYPE_ANS, 19, "Some text")
        A.Write(Strim)

        Dim tempFile = File.Create("C:\1\somefile.txt")
        A.Write(tempFile)
        tempFile.Close()

        Dim B As New Iso8583.Message
        B.SetField(3, FieldTypes.TYPE_N, 6, 0)
        B.SetField(11, FieldTypes.TYPE_N, 6, 0)
        B.SetField(20, FieldTypes.TYPE_ANS, 19, "")

        Console.WriteLine("")
        Console.WriteLine("- - - - -")
        Console.WriteLine("")

        Dim tempFile2 = File.Open("C:\1\somefile2.txt", FileMode.Open)
        B.Read(tempFile2)
        tempFile2.Close()

        B.Write(Strim)

        Console.WriteLine("")
        Console.WriteLine("- - - - -")
        Console.WriteLine("")

        Console.WriteLine("Message type: " & B.Type)
        For Each F In B.Fields
            If F IsNot Nothing Then
                Console.WriteLine(F.Index & " - " & F.Length & " - " & F.Value)
            End If
        Next

        Console.ReadKey()

    End Sub

End Module


